package simonxianyu.learn.springmybatis.util;

import com.fasterxml.jackson.annotation.JsonView;

import java.util.List;

/**
 * DTO for jquery datatable 1.10
 * Created by simon on 2014/12/23.
 */
public class DataTableResult<T> {
    @JsonView(Ajax.Grid.class)
    private Integer draw;
    @JsonView(Ajax.Grid.class)
    private long recordsTotal;
    @JsonView(Ajax.Grid.class)
    private long recordsFiltered;
    @JsonView(Ajax.Grid.class)
    private List<T> data;
    @JsonView(Ajax.Grid.class)
    private String error;

    public DataTableResult() {
    }

  /**
   *
   * @param draw  datatable internal variable
   * @param filtered total result size
   * @param total   size before filter
   * @param data data of table.
   */
    public DataTableResult(Integer draw, long filtered, int total, List<T> data) {
        this.draw = draw;
        this.recordsTotal = total;
        this.recordsFiltered = filtered;
        this.data = data;
    }

    public DataTableResult(Integer draw, long filtered, long total, List<T> data) {
      this.draw = draw;
      this.recordsTotal = total;
      this.recordsFiltered = filtered;
      this.data = data;
    }

    public Integer getDraw() {
        return draw;
    }

    public void setDraw(Integer draw) {
        this.draw = draw;
    }

    public long getRecordsTotal() {
        return recordsTotal;
    }

    public void setRecordsTotal(long recordsTotal) {
        this.recordsTotal = recordsTotal;
    }

    public long getRecordsFiltered() {
        return recordsFiltered;
    }

    public void setRecordsFiltered(long recordsFiltered) {
        this.recordsFiltered = recordsFiltered;
    }

    public List<T> getData() {
        return data;
    }

    public void setData(List<T> data) {
        this.data = data;
    }

    public String getError() {
        return error;
    }

    public void setError(String error) {
        this.error = error;
    }
}
